package jsu.lipengcheng.trafficnet.controlle.user;

import jsu.lipengcheng.trafficnet.common.Result;
import jsu.lipengcheng.trafficnet.pojo.News;
import jsu.lipengcheng.trafficnet.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/news")
public class UserNews {
    @Autowired
    private NewsService newsService;
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/all")
    public Result getAllNews() {

       List<News> newsList = newsService.selectall();
        return Result.success(newsList);
    }

    @GetMapping("/{id}")
    public Result getNewsById(@PathVariable int id) {
        News news=newsService.selectbyid(id);
        return Result.success(news);
    }
}
